package com.wlw.admin.openeye.ui.fragment

import android.os.Bundle
import android.support.v4.app.Fragment
import com.wlw.admin.openeye.R
import com.wlw.admin.openeye.base.BaseFragment
import com.wlw.admin.openeye.base.BaseFragmentAdapter
import com.wlw.admin.openeye.utils.StatusBarUtil
import kotlinx.android.synthetic.main.fragment_hot.*
import kotlinx.android.synthetic.main.fragment_toolbar.*
import kotlin.collections.ArrayList

class DiscoveryFragment : BaseFragment() {
    override fun getLayoutId(): Int = R.layout.fragment_hot
    private val tabList = ArrayList<String>()
    private val fragments = ArrayList<Fragment>()

    companion object {
        fun getInstance(title: String): DiscoveryFragment {
            val fragment = DiscoveryFragment()
            val bundle = Bundle()
            bundle.putString("title", title)
            fragment.arguments = bundle
            return fragment
        }
    }

    override fun lazyLoad() {
    }

    override fun initView() {
        activity?.let {
            StatusBarUtil.darkMode(it)
            StatusBarUtil.setPaddingSmart(it, toolbar)
        }
        tv_header_title.text = arguments?.getString("title") ?: ""
        tabList.add("关注")
        tabList.add("分类")
        fragments.add(FollowFragment.getInstance())
        fragments.add(CategoryFragment.getInstance())
        viewpager.adapter = BaseFragmentAdapter(fragments, tabList, childFragmentManager)
        tabLayout.setupWithViewPager(viewpager)
    }
}